<%--
  Created by IntelliJ IDEA.
  User: User
  Date: 2023/12/22
  Time: 9:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="cn.estore.dao.CustomerDao" %>
<%@ page import="cn.estore.entity.CustomerEntity" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<jsp:useBean id="user" scope="session" class="cn.estore.entity.CustomerEntity">

</jsp:useBean>
<jsp:setProperty name="user" property="*"></jsp:setProperty>
<%
    //会员管理
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");
    Encrypt des=new Encrypt("njcit");//自定义秘钥
    Encrypt
    user.setPassword(des.encrypt(user.getPassword()));
    CustomerDao dao=new CustomerDao();
    int action=Integer.parseInt(request.getParameter("action"));
    switch (action){
        case 0:{//添加会员信息
            CustomerEntity formSelect=dao.selectCustomerEntity(user.getUserName());
            if (formSelect==null||formSelect.equals("")){
                if (dao.insertCustomer(user)){
                    request.setAttribute("registerResult","注册成功!!!");
                }else {
                    request.setAttribute("registerResult","数据库操作失败，注册不成功");
                }
            }else {
                request.setAttribute("registerResult","该用户名存在");
            }
        }
    }
%>
</body>
</html>
